package com.shanghaionstar.mro.util;

import android.os.Handler;
import android.os.Message;

import com.shanghaionstar.utils.FinalConstants;
import com.vcyber.sdk.foro.RecDialogForOListener;

/**
 * Created by 6335yz on 2016/6/20.
 */
public class MyRecDialogForOListener2 extends RecDialogForOListener {
    private Handler myHandler;

    public static MyRecDialogForOListener2 getInstance() {
        return Innerclass.instance;
    }

    static class Innerclass {
        static final MyRecDialogForOListener2 instance = new MyRecDialogForOListener2();
    }

    public void syncHandler(Handler handler) {
        this.myHandler = handler;
    }

    @Override
    public void onTheResult(String arg0) {
        if (myHandler == null)
            return;
        Message msg = myHandler.obtainMessage();
        msg.what = FinalConstants.MroConstants.ONTHERESULT;
        msg.obj = arg0;
        myHandler.sendMessage(msg);
    }

    @Override
    public void onVolume(double arg0) {
        if (myHandler == null)
            return;
        Message msg = myHandler.obtainMessage();
        msg.what = FinalConstants.MroConstants.ONVOLUME;
        msg.obj = arg0;
        myHandler.sendMessage(msg);
    }

    @Override
    public void onPlayVolume(double arg0) {
        if (myHandler == null)
            return;
        Message msg = myHandler.obtainMessage();
        msg.what = FinalConstants.MroConstants.ONPLAYVOLUME;
        msg.obj = arg0;
        myHandler.sendMessage(msg);
    }

    @Override
    public void onEndPlay() {
        if (myHandler == null)
            return;
        super.onEndPlay();
        Message msg = myHandler.obtainMessage();
        msg.what = FinalConstants.MroConstants.ONENDPLAY;
        myHandler.sendMessage(msg);
    }

    public void release() {
        syncHandler(null);
    }

}
